#include "junix.h"
using namespace std;

struct A {
	A(int n=0) :n(n) { }
	int n;
	friend ostream& operator<<(ostream& os, const A& a) {
		os<<setw(3)<<setfill('_')<<a.n;
		return os;
	}
};

struct B {
	B(int i=0):n(i) {}
	int n;
};

struct Hash {
	std::size_t operator() (const A& a) const {
		return std::size_t(a.n);
	}
};

struct Equal_A : public binary_function<A,A,bool>
{
	bool operator() (const A& lhs, const A&  rhs) const {
		return lhs.n==rhs.n;
	}
};

int main(int argc, char **argv)
{
	typedef __gnu_cxx::hash_map<A,int,Hash,Equal_A> AMAP;
	AMAP dict;

	for (int i=0;i<100;i++) {
		dict[A(i)] = rand()%100;
	}

	BOOST_FOREACH(AMAP::value_type& v,dict) {
		cout<<v.first<<" "<<v.second<<endl;
	}
}
